﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BaiTu.BLL
{
    public class ChannelBLL : Repository<DTOS.ChannelDTO>, IBLL.IChannelBLL
    {
        private IDAL.IRepository<Domains.ChannelEntity> _repository;

        public IDAL.IRepository<Domains.ChannelEntity> Repository { get { return _repository; } }
        public ChannelBLL()
        {
            _repository = CurrentEngineContext.Resolve<IDAL.IRepository<Domains.ChannelEntity>>();
        }
        public override Framework.InnerResult Add(DTOS.ChannelDTO entity)
        {
            Domains.ChannelEntity channelEntity = new Domains.ChannelEntity();
            TypeDtoToDomainConvert(channelEntity, entity);
            return _repository.Add(channelEntity);
        }
        public override Framework.InnerResult Delete(DTOS.ChannelDTO entity)
        {
            Domains.ChannelEntity channelEntity = new Domains.ChannelEntity();
            TypeDtoToDomainConvert(channelEntity, entity);
            return _repository.Delete(channelEntity);
        }
        public override Framework.InnerResult Update(DTOS.ChannelDTO entity)
        {
            Domains.ChannelEntity channelEntity = new Domains.ChannelEntity();
            TypeDtoToDomainConvert(channelEntity, entity);
            return _repository.Update(channelEntity);
        }
        public override DTOS.ChannelDTO FindByID(string id)
        {
            var channelEntity = _repository.GetById(id);
            DTOS.ChannelDTO channelDTO = new DTOS.ChannelDTO();
            TypeDomainToDTOConvert(channelEntity, channelDTO);
            return channelDTO;
        }
        public override int GetCount()
        {
            return _repository.TableNoTracking.Count();
        }
        public override long GetLongCount()
        {
            return _repository.TableNoTracking.LongCount();
        }
    }
}
